﻿using System;
using System.Linq;
using Wicresoft.EKA.MVCExtensions;
using Wicresoft.EKA.ITSM.Business;
using System.Collections.Generic;

namespace Wicresoft.EKA.ITSM.BusinessImpl
{
    public class SMGXJPlanRule : Base ,ISMGXJPlanRule
    {
        protected override void Dispose(bool disposing)
        {
        }

        public IEnumerable<SMGXJPlanRuleModel> GetList(string Qual)
        {
            var proxy = this.GetARProxy<SMGXJPlanRuleModel>();
            var list = proxy.GetListEntry(Qual, new System.Collections.Generic.List<uint>()
                {
                    SMGXJPlanRuleModel.RequestID_ID,
                    SMGXJPlanRuleModel.cChr_RuleType_ID,
                    SMGXJPlanRuleModel.cChr_Threshold_ID,
                    SMGXJPlanRuleModel.cChr_Permission_ID,
                    SMGXJPlanRuleModel.cChr_RuleName_ID,
                    SMGXJPlanRuleModel.cChr_RuleValue_ID
                });
            return list;
        }


        public string Create(SMGXJPlanRuleModel model)
        {
            try
            {
                var proxy = this.GetARProxy<SMGXJPlanRuleModel>();
                var list = proxy.CreateEntry(model);

                return list;
            }
            catch (Exception e)
            {
                throw e;
            }         
        }

        public string Modify(SMGXJPlanRuleModel model, string Qual)
        {
            try
            {
                var proxy = this.GetARProxy<SMGXJPlanRuleModel>();
                proxy.SetEntryByQuery(model, Qual, BMC.ARSystem.Server.SetEntryByQuery_NoMatchOption.NoAction, BMC.ARSystem.Server.SetEntryByQuery_MultiMatchOption.ModifyAll);
                return "Success";
            }
            catch (Exception e)
            {
                return "Fail:" + e.Message;
            }
        }
    }
}
